<?php
Class UserModel Extends CI_Model
{
	var $Id;
	var $UserName;
	var $Password;
	var $FisrtName;
	var $LastName;
	var $Address;
	var $Phone;
	var $Fax;
	var $CreatedBy;
	var $ModifiedBy;
	var $CreatedDate;
	var $ModifiedDate;
	
	function __construct()
	{
		parent::__construct();
	}
	
	function insert($user)
	{
		$result = $this->db->insert('user', $user);
		return $result;
	}
	
	function update($user)
	{
		$this->db->where('Id', $user->Id);
		$result = $this->db->update('user', $user);
		return $result;
	}
	
	function getsAll()
	{
		$result = array();
		$query = $this -> db -> query('select * from user');
		$index = 1;
		foreach ($query->result() as $row)
		{
			$result[$index++] = $row;
		}
		return $result;
	}

	function getsPage($offset, $length)
	{
		$result = array();
		$this->db->select('*');
		$this->db->from('user');
		$this->db->order_by('Id');
		$this->db->limit($length, $offset);
		$query= $this->db->get();
		$index = 1;
		foreach ($query->result() as $row)
		{
			$result[$index++] = $row;
		}
		return $result;
	}

	function getById($Id)
	{
		$query = $this -> db -> query('select * from user where id='.$Id);
		if($query -> num_rows() > 0)
		{
			$rows = $query -> row_array();
		}
		return $rows;
	}
}
?>